home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / packet / p_aa4re / bb212src / bbsetupg.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-03-12  |  13.8 KB  |  422 lines

  1. (*===========================================================================*)
  2. (* Get parm setup routine                                                    *)
  3. (*                                                                           *)
  4. (*   Copyright 1988, 1989, 1990, 1991 by H. Roy Engehausen.  All rights      *)
  5. (*   reserved.                                                               *)
  6. (*                                                                           *)
  7. (*===========================================================================*)
  8.  
  9. (*===========================================================================*)
  10. (* Get the parm                                                              *)
  11. (*===========================================================================*)
  12.  
  13. PROCEDURE get_the_parm(p : parm_array_ptr);
  14.  
  15.   VAR
  16.     e_str      : STRING;
  17.     log_ext    : EXTSTR;
  18.     log_file   : NAMESTR;
  19.     log_path   : DIRSTR;
  20.     i          : BYTE;
  21.     j          : BYTE;
  22.     parm_index : BYTE;
  23.     t_str      : STRING;
  24.     t_scb      : str_chain_ptr;
  25.  
  26.   VAR
  27.     p_things : RECORD
  28.                  CASE BYTE OF
  29.                    0: (p_byte     : ^BYTE);
  30.                    1: (p_char     : ^CHAR);
  31.                    2: (p_integer  : ^INTEGER);
  32.                    3: (p_str      : ^STRING);
  33.                    4: (p_word     : ^WORD);
  34.                    5: (p_long_int : ^LONGINT);
  35.                    6: (p_user_cl  : ^user_class_type);
  36.                    7: (p_strchn   : ^str_chain_ptr);
  37.                    8: (p_boolean  : ^BOOLEAN);
  38.                    9: (p_access   : access_block_ptr);
  39.                END;
  40.  
  41.   BEGIN;
  42.  
  43.     parm_index := 1;
  44.     WHILE (parm_index <= parm_max) AND (p^[parm_index].parm_name <> p_name) DO
  45.       INC(parm_index);
  46.  
  47.     IF parm_index > parm_max THEN
  48.       BEGIN;
  49.         err_line('Invalid parameter name -- ' + p_name);
  50.         EXIT;
  51.       END;
  52.  
  53.     IF p = @port_parm_array THEN
  54.       BEGIN;
  55.  
  56.         IF (work_port.port_type = port_modem)
  57.                     AND ((parm_index = port_parm_call)
  58.                                          OR (parm_index = port_parm_bcst)) THEN
  59.           BEGIN;
  60.             err_line('This parameter not valid for modems');
  61.             EXIT;
  62.           END;
  63.  
  64.         IF (parm_index = port_parm_ring)
  65.                                 AND (work_port.port_type <> port_modem)
  66.                                 AND (work_port.port_type <> port_null_modem)
  67.                                 AND (work_port.port_type <> port_unknown) THEN
  68.           BEGIN;
  69.             err_line('This parameter not valid for non-modems');
  70.             EXIT;
  71.           END;
  72.  
  73.       END;
  74.  
  75.     p_things.p_str := p^[parm_index].parm_addr;
  76.  
  77.     WITH p^[parm_index] DO
  78.       IF (attr_did_this IN parm_attr)
  79.                                    AND NOT(attr_multiple_ok IN parm_attr) THEN
  80.         err_line('This parameter is already set -- ' + p_name)
  81.       ELSE
  82.         parm_attr := parm_attr + [attr_did_this];
  83.  
  84.     WITH p^[parm_index], p_things DO
  85.       CASE parm_type OF
  86.  
  87.         parm_obsolete:
  88.                 BEGIN;
  89.                   warn_line('This parameter is obsolete and has been ignored.'
  90.                              + '  See CONVERT.DOC.');
  91.                 END;
  92.  
  93.         parm_string , parm_string_upper, parm_string_under, parm_char_upper,
  94.         parm_path , parm_file, parm_file_not_exist, parm_log:
  95.                BEGIN;
  96.  
  97.                  IF (parm_type = parm_string_upper)
  98.                                         OR (parm_type = parm_string_under)
  99.                                         OR (parm_type = parm_char_upper)
  100.                                         OR (parm_type = parm_log) THEN
  101.                    BEGIN;
  102.                      upcase_str_var(p_value);
  103.                      IF parm_type = parm_string_under THEN
  104.                        BEGIN;
  105.                          i := POS('_', p_value);
  106.                          IF i <> 0 THEN
  107.                            p_value[i] := ' ';
  108.                        END;
  109.                    END;
  110.  
  111.                  IF (p_value = 'NONE') AND (parm_type <> parm_log) THEN
  112.                    p_value := '';
  113.  
  114.                  IF LENGTH(p_value) >= parm_str_len THEN
  115.                    BEGIN;
  116.                      err_line('Parm is too long');
  117.                      EXIT;
  118.                    END;
  119.  
  120.                  IF parm_type <> parm_char_upper THEN
  121.                    p_str^ := p_value
  122.                  ELSE
  123.                    p_char^ := p_value[1];
  124.  
  125.                  IF parm_type = parm_log THEN
  126.                    BEGIN;
  127.                      FSPLIT(p_value, log_path, log_file, log_ext);
  128.                      IF (log_ext = '')
  129.                            AND ((log_file = 'WEEKLY')
  130.                                      OR (log_file = 'MONTHLY')
  131.                                      OR (log_file = 'DAILY')
  132.                                      OR (log_file = 'NONE')) THEN
  133.                        BEGIN;
  134.                          p_value   := log_path;
  135.                          parm_type := parm_path;
  136.                        END
  137.                      ELSE
  138.                        parm_type := parm_file_not_exist;
  139.                    END;
  140.  
  141.                  IF (parm_type <> parm_path) AND
  142.                                (parm_type <> parm_file) AND
  143.                                (parm_type <> parm_file_not_exist) THEN
  144.                    EXIT;
  145.  
  146.                  work_str := p_value;
  147.  
  148.                  IF parm_type = parm_path THEN
  149.                    IF (LENGTH(work_str) > 0) AND (work_str <> 'ANY') AND
  150.                                     (work_str[LENGTH(work_str)] <> '\') AND
  151.                                     (work_str[LENGTH(work_str)] <> ':') THEN
  152.                      BEGIN;
  153.                        err_line('Invalid format for path');
  154.                        EXIT;
  155.                      END
  156.                    ELSE
  157.                      work_str := work_str + '*.*';
  158.  
  159.                  b := test_file(work_str, parm_type <> parm_file);
  160.  
  161.                  IF NOT b THEN
  162.                    err_line('Error during check');
  163.  
  164.                END;
  165.  
  166.         parm_byte, parm_integer, parm_word, parm_long_int:
  167.                BEGIN;
  168.  
  169.                  VAL(p_value, i_value, code);
  170.                  IF code <> 0 THEN
  171.                    BEGIN;
  172.                      err_line('Parameter not numeric');
  173.                      EXIT;
  174.                    END;
  175.  
  176.                  IF (i_value < parm_lo) OR (i_value > parm_hi) THEN
  177.                    BEGIN;
  178.                      e_str := 'Number must be between ';
  179.                      STR(parm_lo, t_str);
  180.                      e_str := e_str + t_str + ' and ';
  181.                      STR(parm_hi, t_str);
  182.                      e_str := e_str + t_str;
  183.                      err_line(e_str);
  184.                      EXIT;
  185.                    END;
  186.  
  187.                  CASE parm_type OF
  188.                    parm_byte     : p_byte^     := i_value;
  189.                    parm_integer  : p_integer^  := i_value;
  190.                    parm_word     : p_word^     := i_value;
  191.                    parm_long_int : p_long_int^ := i_value;
  192.                    ELSE
  193.                      BEGIN;
  194.                        WRITELN('Bad parm type in number eval --',
  195.                                                              ORD(parm_type));
  196.                        HALT;
  197.                      END;
  198.                  END;
  199.  
  200.                END;
  201.  
  202.         parm_boolean:
  203.                p_boolean^ := yn;
  204.  
  205.         parm_speed:
  206.                WITH work_port DO
  207.                  BEGIN;
  208.  
  209.                    VAL(p_value, i_value, code);
  210.                    IF code <> 0 THEN
  211.                      BEGIN;
  212.                        err_line('Parameter not numeric');
  213.                        EXIT;
  214.                      END;
  215.  
  216.                    data_rate := i_value;
  217.  
  218.                    IF i_value =  300 THEN EXIT;
  219.                    IF i_value = 1200 THEN EXIT;
  220.                    IF i_value = 2400 THEN EXIT;
  221.                    IF i_value = 4800 THEN EXIT;
  222.                    IF i_value = 9600 THEN EXIT;
  223.  
  224.                    err_line('Invalid speed setting');
  225.                    EXIT;
  226.  
  227.                  END;
  228.  
  229.         parm_port_type:
  230.                WITH work_port DO
  231.                  BEGIN;
  232.  
  233.                    upcase_str_var(p_value);
  234.  
  235.                    IF p_value = 'TNC-1' THEN
  236.                      BEGIN;
  237.                        port_type := port_dedhost1;
  238.                        EXIT;
  239.                      END;
  240.  
  241.                    IF p_value = 'TNC-2' THEN
  242.                      BEGIN;
  243.                        port_type := port_dedhost2;
  244.                        EXIT;
  245.                      END;
  246.  
  247.                    IF p_value = 'PK-87-DED' THEN
  248.                      BEGIN;
  249.                        port_type := port_dedhost87;
  250.                        EXIT;
  251.                      END;
  252.  
  253.                    IF p_value = 'G8BPQ-HOST' THEN
  254.                      BEGIN;
  255.                        port_type := port_bpqhost;
  256.                        port_num  := '0';
  257.                        EXIT;
  258.                      END;
  259.  
  260.                    IF (LENGTH(p_value) = 12)
  261.                                   AND (substr(p_value, 1, 11) = 'G8BPQ-HOST-')
  262.                                   AND (p_value[12] >  '0')
  263.                                   AND (p_value[12] <= '9') THEN
  264.                      BEGIN;
  265.                        port_type := port_bpqhost;
  266.                        port_num  := p_value[12];
  267.                        EXIT;
  268.                      END;
  269.  
  270.                    IF p_value = 'PK-87-AEA' THEN
  271.                      BEGIN;
  272.                        port_type := port_aeapk232;
  273.                        EXIT;
  274.                      END;
  275.  
  276.                    IF p_value = 'PK-232' THEN
  277.                      BEGIN;
  278.                        port_type := port_aeapk232;
  279.                        EXIT;
  280.                      END;
  281.  
  282.                    IF p_value = 'PC-1XX' THEN
  283.                      BEGIN;
  284.                        port_type := port_pc1xx;
  285.                        EXIT;
  286.                      END;
  287.  
  288.                    IF p_value = 'MODEM-ATCMD' THEN
  289.                      BEGIN;
  290.                        port_type := port_modem;
  291.                        EXIT;
  292.                      END;
  293.  
  294.                    IF p_value = 'MODEM-NULL' THEN
  295.                      BEGIN;
  296.                        port_type := port_null_modem;
  297.                        EXIT;
  298.                      END;
  299.  
  300.                    IF (p_value = 'G8BPQ-NODE') OR (p_value = 'G8BPQ_NODE') THEN
  301.                      BEGIN;
  302.                        port_type := port_g8bpq;
  303.                        EXIT;
  304.                      END;
  305.  
  306.                    IF (LENGTH(p_value) = 7)
  307.                                       AND (substr(p_value, 1, 6) = 'PC*PA-')
  308.                                       AND (p_value[7] >= '0')
  309.                                       AND (p_value[7] <= '7') THEN
  310.                      BEGIN;
  311.                        port_type := port_pcpa;
  312.                        port_num  := p_value[7];
  313.                        EXIT;
  314.                      END;
  315.  
  316.                    err_line('Port type not valid');
  317.  
  318.                  END;
  319.  
  320.         parm_user_class:
  321.                BEGIN;
  322.  
  323.                  upcase_str_var(p_value);
  324.  
  325.                  IF p_value = 'NEW_USER' THEN
  326.                      BEGIN;
  327.                        p_user_cl^ := user_c_nu;
  328.                        EXIT;
  329.                      END;
  330.  
  331.                  IF p_value = 'UNREGISTERED_USER' THEN
  332.                      BEGIN;
  333.                        p_user_cl^ := user_c_uu;
  334.                        EXIT;
  335.                      END;
  336.  
  337.                  IF p_value = 'USER' THEN
  338.                      BEGIN;
  339.                        p_user_cl^ := user_c_ou;
  340.                        EXIT;
  341.                      END;
  342.  
  343.                  IF p_value = 'EXPERT' THEN
  344.                      BEGIN;
  345.                        p_user_cl^ := user_c_eu;
  346.                        EXIT;
  347.                      END;
  348.  
  349.                  IF p_value = 'BBS' THEN
  350.                      BEGIN;
  351.                        p_user_cl^ := user_c_bu;
  352.                        EXIT;
  353.                      END;
  354.  
  355.                  IF p_value = 'REMOTE_SYSOP' THEN
  356.                      BEGIN;
  357.                        p_user_cl^ := user_c_rsu;
  358.                        EXIT;
  359.                      END;
  360.  
  361.                  IF p_value = 'LOCAL_SYSOP' THEN
  362.                      BEGIN;
  363.                        p_user_cl^ := user_c_lsu;
  364.                        EXIT;
  365.                      END;
  366.  
  367.                    err_line('User class not valid');
  368.  
  369.                END;
  370.  
  371.         parm_str_chain,
  372.         parm_str_chain_up:
  373.                BEGIN;
  374.  
  375.                  IF parm_type = parm_str_chain_up THEN
  376.                    upcase_str_var(p_value);
  377.  
  378.                  NEW(t_scb);
  379.  
  380.                  WITH t_scb^ DO
  381.                    BEGIN;
  382.                      str_data  := p_value;
  383.                      str_next  := p_strchn^;
  384.                      p_strchn^ := t_scb;
  385.                    END;
  386.  
  387.                END;
  388.  
  389.           parm_access:
  390.             BEGIN;
  391.  
  392.               p_access^.access_flags := 0;
  393.  
  394.               FOR i_value := 1 TO LENGTH(p_value) DO
  395.                 BEGIN;
  396.  
  397.                   j := POS(p_value[i_value], access_letter_group);
  398.                   IF j = 0 THEN
  399.                     BEGIN;
  400.                       err_line('Invalid character in access list -- ' +
  401.                                p_value[i_value]);
  402.                       EXIT;
  403.                     END;
  404.  
  405.                   IF j > 1 THEN
  406.                     i := $80 SHR (j-1)
  407.                   ELSE
  408.                     i := $80;
  409.  
  410.                   p_access^.access_flags := p_access^.access_flags OR i;
  411.  
  412.                 END;
  413.  
  414.             END;
  415.  
  416.         ELSE
  417.           err_line('Mismatched scan table -- ' + p_name);
  418.  
  419.       END;
  420.  
  421.   END;
  422.